package com.scorpio.basic.service.impl;

import com.scorpio.basic.domain.HomeListEntity;
import com.scorpio.basic.dto.HomeListDTO;
import com.scorpio.basic.mapper.HomeListMapper;
import com.scorpio.basic.service.HomeListResService;
import com.scorpio.basic.service.HomeListService;
import com.scorpio.common.service.impl.BaseServiceImpl;
import com.scorpio.common.utils.ConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HomeListServiceImpl extends BaseServiceImpl<HomeListMapper, HomeListEntity> implements HomeListService {

    @Autowired
    private HomeListResService resService;

    @Override
    public List<HomeListDTO> appList() {
        List<HomeListDTO> list = ConvertUtils.sourceToTarget(baseDao.appList(), HomeListDTO.class);
        for (HomeListDTO listDTO : list) {
            listDTO.res = resService.selectByHomeList(listDTO.getId());
        }
        return list;
    }
}
